#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
@Project : aimix
@File    : audio_and_video_separation_wowrker.py
@IDE     : PyCharm
@Author  : admin
@Date    : 2025/4/22 09:48
"""

import traceback
from PyQt5.QtCore import pyqtSignal, QThread
from utils.load_file import load_files
from core.audio.extract_audio import batch_extract_video_and_audio


class AudioAndVideoSeparationWorker(QThread):
    """音视频分离线程"""
    failed = pyqtSignal(Exception)

    def __init__(self, input_files, output_folder, parent=None):
        super(AudioAndVideoSeparationWorker, self).__init__()
        self.input_files = input_files
        self.output_folder = output_folder

    def run(self):
        try:
            task_files = load_files(self.input_files)
            batch_extract_video_and_audio(task_files, self.output_folder)
        except Exception as e:
            self.failed.emit(e)
            traceback.print_exc()


